import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats

fig,ax = plt.subplots(1,1)
p = 0.5


#ppf:累积分布函数的反函数。q=0.01时，ppf就是p(X<x)=0.01时的x值。
x = np.arange(stats.geom.ppf(0.01, p),stats.geom.ppf(0.99, p))

ax.plot(x, stats.geom.pmf(x, p),'o')
ax.plot(x, stats.geom.pmf(x, 0.7),'o')

plt.show()